package com.buaa.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.buaa.dto.LocationDTO;
import com.buaa.entity.DriverAccidentDesc;
import com.buaa.enums.ResponseCode;
import com.buaa.exception.ServiceException;
import com.buaa.mapper.DriverAccidentDescMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DriverAccidentDescServiceImpl extends ServiceImpl<DriverAccidentDescMapper, DriverAccidentDesc> implements IService<DriverAccidentDesc> {

    @Autowired
    private DriverAccidentDescMapper accidentDescMapper;

    public List<LocationDTO> byDriverAccidentVehicleType(){
        List<LocationDTO> locationDTOS = null;
        try {
            // 复用 LocationDTO ， 年龄，用户数
            locationDTOS = accidentDescMapper.byDriverAccidentVehicleType();
        } catch (ServiceException e) {
            new ServiceException(ResponseCode.DB_EXEC_ERROR.getKey(), ResponseCode.DB_EXEC_ERROR.getDesc());
        }
        return locationDTOS;
    }

    public List<LocationDTO> byDriverAccidentGender(){
        List<LocationDTO> locationDTOS = null;
        try {
            // 复用 LocationDTO ， 年龄，用户数
            locationDTOS = accidentDescMapper.byDriverAccidentGender();
        } catch (ServiceException e) {
            new ServiceException(ResponseCode.DB_EXEC_ERROR.getKey(), ResponseCode.DB_EXEC_ERROR.getDesc());
        }
        return locationDTOS;
    }

    public List<LocationDTO> byDriverAccidentAge(){
        List<LocationDTO> locationDTOS = null;
        try {
            // 复用 LocationDTO ， 年龄，用户数
            locationDTOS = accidentDescMapper.byDriverAccidentAge();
        } catch (ServiceException e) {
            new ServiceException(ResponseCode.DB_EXEC_ERROR.getKey(), ResponseCode.DB_EXEC_ERROR.getDesc());
        }
        return locationDTOS;
    }

    public List<LocationDTO> byDriverAccidentTime(){
        List<LocationDTO> locationDTOS = null;
        try {
            // 复用 LocationDTO ， 年龄，用户数
            locationDTOS = accidentDescMapper.byDriverAccidentTime();
        } catch (ServiceException e) {
            new ServiceException(ResponseCode.DB_EXEC_ERROR.getKey(), ResponseCode.DB_EXEC_ERROR.getDesc());
        }
        return locationDTOS;
    }
}

